package com.digital.smartgrow.controller.business;

import com.digital.smartgrow.common.advice.Result;
import com.digital.smartgrow.dto.business.UpProcessLogPageDTO;
import com.digital.smartgrow.entity.business.UpProcessLog;
import com.digital.smartgrow.service.business.UpProcessLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 审批明细 前端控制器
 * </p>
 *
 * @author sunyuechao
 * @since 2022-07-13
 */
@Api(tags = "审批明细")
@RestController
@RequestMapping("${context.prefix}/business/upProcessLog")
public class UpProcessLogController {

    @Autowired
    private UpProcessLogService upProcessLogService;

    @ApiOperation(value = "审批明细-分页查询")
    @PostMapping("/list")
    public Object getListByPage(@RequestBody UpProcessLogPageDTO upProcessLogPageDTO){
        return upProcessLogService.getListByPage(upProcessLogPageDTO);
    }

    @ApiOperation(value = "审批明细-详情")
    @GetMapping("/{id}")
    public Object getInfo(@PathVariable Integer id){
        if (id == null) return Result.fail("id不能为空");
        return upProcessLogService.getInfo(id);
    }

//    @ApiOperation(value = "审批明细-删除")
//    @DeleteMapping("/{id}")
    public Object removeById(@PathVariable Integer id){
      if (id == null) return Result.fail("id不能为空");
      return upProcessLogService.removeById(id);
    }
//    @ApiOperation(value = "审批明细-新增")
//    @PostMapping()
    public Object add( @RequestBody UpProcessLog upProcessLog){
       return upProcessLogService.save(upProcessLog);
    }

//    @ApiOperation(value = "审批明细-编辑")
//    @PutMapping()
    public Object edit(@RequestBody UpProcessLog upProcessLog){
    if (upProcessLog==null||upProcessLog.getId() == null)
       return Result.fail("id不能为空");
       return upProcessLogService.updateById(upProcessLog);
    }
}
